# -*- coding: utf-8 -*-
# @Time    : 2021/4/28 0028 9:47
# @Author  : 蒋才果
# @Email   : 1476235300@qq.com
# @File    : 高阶函数.py
# @Software: PyCharm
# #1
# def func(x,y):
#      return str(x) + str(y)
# lst = [1,4,5,6]
# print(reduce(func,lst))
#
# 2
# lst = [1,2,3,4,5,6,7,8,9,10]
# print(list(map(lambda x:x*x,lst)))
#
#3
# lst = list()
# for i in range(1,100):
#     lst.append(i)
# print(list(filter(lambda x:x%3==0,lst)))
#
#4
# lst = [1,2,3,5,6]
# print(reduce(lambda x,y:x*y,lst))
#
#5
# import re
# def func1(username):
#     if re.search(r"\b[^\d][A-z_0-9]{5,17}\b",username):
#         return username
#     else:
#         return False
# # username = input("::::")
# username = ['d3892754','53642879','f_5423','fsdlhjk547fg652fd543890fdshjkl','d34']
# print(list(map(func1,username)))
# print(list(filter(func1,username)))

# 6
# ls = []
# ls2 = []
# lst = [7,-8,5,8,0,-2,-5]
# for i in lst:
#     if i >= 0:
#         ls.append(i)
#     else:
#         ls2.append(i)
# print(sorted(ls)+sorted(ls2,reverse=True))
# print(sorted(lst,key=lambda x:(x<0,abs(x))))

lst = [7, -8, 5, 40000, 0, -2, -5, -0.5]
# max_num = max(lst)
#print(sorted(lst,key=lambda x:max(lst)-x if x<0 else x))
#lst.sort(key=lambda x: x*-max_num if x < 0 else x )
# print(lst)

# def func7(a):
#     n=0
#     for i in range(len(a)):
#         if str(a[i]).isdigit():
#             if n==0:
#                 n=i
#             elif int(a[i])%2!=0:
#                  a.insert(n,a[i])
#                  del a[i+1:i+2]
#     return a
#
# s = 'asdf234GDSdfd47904sf23'
# b=sorted(s,key=ascii)[::-1]
# d=func7(b)
# print(d)